chore: Compatibility with fee based tokens#330
Conversation
| version: TokenVersion; | ||
|
|
||
| transactions: number; | ||
|
|
||
| constructor(id: string, name: string, symbol: string, transactions?: number) { | ||
| this.id = id; | ||
| this.name = name; | ||
| this.symbol = symbol; | ||
| this.version = TokenVersion.DEPOSIT; // Hardcoded for now, while the Fee Tokens implementation is not complete |
There was a problem hiding this comment.
The new version property is not covered by existing tests. The test at line 1260 in tests/db.test.ts uses toStrictEqual to compare TokenInfo objects, which will now include the version field in the comparison. However, since both the stored and retrieved TokenInfo objects will have the same hardcoded TokenVersion.DEPOSIT value (due to the bug where version is not persisted), the test will pass even though the version functionality is not working correctly.
Consider adding explicit test cases that:
- Verify the version field is correctly set for native tokens (should be NATIVE)
- Verify the version field is correctly set for custom tokens (should match what was stored)
- Test that different token versions can be stored and retrieved correctly
| /** | ||
| * Token version used to identify the type of token during the token creation process. | ||
| */ | ||
| export enum TokenVersion { | ||
| NATIVE = 0, | ||
|
|
||
| DEPOSIT = 1, | ||
|
|
||
| FEE = 2, | ||
| } |
There was a problem hiding this comment.
The JSDoc comment for the TokenVersion enum mentions it's used "during the token creation process," but this doesn't fully explain what each version type means or when each should be used. Consider expanding the documentation to clarify:
- What differentiates NATIVE, DEPOSIT, and FEE tokens
- Which version should be used for which scenarios
- Any implications or restrictions for each version type
This will help future developers understand how to properly use these token version types.
|
This PR was supposed to solve an issue in HathorNetwork/hathor-wallet-lib#949 , but a workaround was implemented there instead. The Fee Based tokens will be implemented in a dedicated PR in the future. |
Motivation
The changes on Fee Token Creation ( HathorNetwork/hathor-wallet-lib#858 ) have created a compatibility issue for the tests inside HathorNetwork/hathor-wallet-lib#949 . This PR aims to solve this compatibility minimally before the actual implementation of the fee-based tokens are made here.
Acceptance Criteria
Checklist
master, confirm this code is production-ready and can be included in future releases as soon as it gets merged